package LC;

/**
 * @ClassName LC543
 * @Description: TODO
 * @Author hl
 * @Date 2020/5/29
 * @Version V1.0
 **/
public class LC543 {
    int result=0;
    public int diameterOfBinaryTree(TreeNode root) {
        if(root==null){
            return  0;
        }
        deep(root);
        return  result;
    }

    private int deep(TreeNode root) {
        if(root==null){
            return 0;
        }
        int left=deep(root.left);
        int right=deep(root.right);

        result=Math.max(result,left+right+1);
        return Math.max(left,right)+1;

    }

}
